#pragma once

#include <QMainWindow>
#include <QTableWidget>
#include <QPushButton>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include "mavlink/common/mavlink.h"
#include "mavlink_server.h"
#include "controlW.h"
#include "dataView.h"

Q_DECLARE_METATYPE(mavlink_message_t)

class MainWindow : public QMainWindow {
    Q_OBJECT // 确保包含这个宏

public:
    MainWindow(QWidget *parent = nullptr);

private slots:
    void serverLinkClicked(const std::string ip, int port);
    void cmdBtnClicked(const int cmd_type , const int drone_id, const std::vector<float> data_f, 
                        const std::vector<int> data_i, const std::string data_s);
    void handleMavlinkMessage(const mavlink_message_t& message);

public: signals:
    void mavlinkMessageReceived(const mavlink_message_t& message);

private:
    int seq_{0}; // 发送的序列号
    Control *control_;
    DataView *dataView_;
    MavlinkServer mavlinkServer;

    void createConnect(); // 创建连接
};